<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>HTML 链接生成二维码</title>
    <!-- 引入 qr-code-styling 库 -->
    <script src="https://cdn.jsdelivr.net/npm/qr-code-styling@1.5.0/lib/qr-code-styling.min.js"></script>
</head>

<body>
    <!-- 用于显示二维码的容器 -->
    <canvas id="qrcode"></canvas>

    <script>
        // 要生成二维码的链接
        const queryString = window.location.search;
        const urlParams = new URLSearchParams(queryString);
        const link = location.origin+urlParams.get("path");

        // 创建二维码对象
        const qrCode = new QRCodeStyling({
            width: 300,
            height: 300,
            type: "canvas",
            data: link,
            dotsOptions: {
                color: "#4267b2",
                type: "rounded"
            },
            backgroundOptions: {
                color: "#e9ebee"
            }
        });

        // 将二维码渲染到指定容器中
        qrCode.append(document.getElementById("qrcode"));
    </script>
</body>

</html>